package butines.kraz.state;

import butines.kraz.entity.AbstractState;
import butines.kraz.entity.Unit;

public class UnitDieState extends AbstractState<Unit> {

	private static final UnitDieState instance = new UnitDieState();

	public static UnitDieState getInstance() {
		return instance;
	}
	
	@Override
	public void enter(Unit unit) {
		unit.setSpeed(0);
		unit.getSprite().play("die");
		
	}

	@Override
	public void leave(Unit unit) {

	}

	@Override
	public void execute(Unit unit) {

		if (unit.getSprite().isPlayed("die")) {
			unit.setAlive(false);
			unit.changeState(null);
		}
		
	}

}
